package day6;

import java.util.Objects;

public class Card {
    public static int SUIT_NULL;
    public static int RANK_QUEEN;
    public static int RANK_KING;
    //点数 3-10, J,Q,K,A,2
    private int rank;
    //花色 ♥,♦,♣,♠
    private int suit;

    public static final int RANK_3 = 0;
    public static final int RANK_4 = 1;
    public static final int RANK_5 = 2;
    public static final int RANK_6 = 3;
    public static final int RANK_7 = 4;
    public static final int RANK_8 = 5;
    public static final int RANK_9 = 6;
    public static final int RANK_10 = 7;
    public static final int RANK_J = 8;
    public static final int RANK_Q = 9;
    public static final int RANK_K = 10;
    public static final int RANK_A = 11;
    public static final int RANK_2 = 12;

    public static final int SUIT_HEITAO = 0;
    public static final int SUIT_HONGTAO = 1;
    public static final int SUIT_MEITUAN = 2;
    public static final int SUIT_FANGKUAI = 3;
    // 在Card类中添加以下常量定义
    public static final int RANK_SMALL_JOKER = 13;
    public static final int RANK_BIG_JOKER = 14;
    public static final int SUIT_JOKER = -1;

    // 同时需要修改 RANKS 数组以支持大小王显示
// 将原来的 RANKS 定义修改为：
    private static final String[] RANKS = {"3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A", "2", "小王", "大王"};

    // 将原来的 SUITS 定义修改为：
    private static final String[] SUITS = {"♠", "♥", "♣", "♦", ""}; // 最后一个空字符串用于大小王







    @Override
    public String toString() {
        // 处理大小王的特殊情况
        if (rank >= RANK_SMALL_JOKER) {
            return RANKS[this.rank];
        }
        // 处理普通牌
        if (suit >= 0 && suit < SUITS.length && rank >= 0 && rank < RANKS.length) {
            return SUITS[this.suit] + RANKS[this.rank];
        }
        return "未知牌";
    }


    @Override
    public boolean equals(Object o) {
        if (!(o instanceof Card card)) return false;
        return rank == card.rank && suit == card.suit;
    }

    @Override
    public int hashCode() {
        return Objects.hash(rank, suit);
    }

    public Card(int rank, int suit) {
        this.rank = rank;
        this.suit = suit;
    }

    public int getRank(){
        return rank;
    }

    public int getSuit(){
        return suit;
    }

    public void setRank(int rank){
        this.rank = rank;

    }

    
}